package per.turtle.common.core.web.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import per.turtle.common.core.annotation.MaxSizeWithCharset;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * Entity基类
 *
 * @author turtle
 */
@ApiModel(value = "通用基础对象")
@Data
@EqualsAndHashCode(callSuper = true)
@JsonIgnoreProperties(allowGetters = true, value = {"createBy", "createTime", "updateBy", "updateTime"})
public class BaseEntity extends Query implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("创建者")
    @ExcelIgnore
    @TableField(fill = FieldFill.INSERT)
    private String createBy;

    @ApiModelProperty("创建时间")
    @ExcelIgnore
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @ApiModelProperty("更新者")
    @ExcelIgnore
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updateBy;

    @ApiModelProperty("更新时间")
    @ExcelIgnore
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    @ApiModelProperty("是否已删除")
    @ExcelIgnore
    @JsonIgnore
    @TableLogic
    private Boolean isDeleted;

    @ApiModelProperty("备注")
    @ExcelProperty("备注")
    @MaxSizeWithCharset(max = 80, message = "备注超出限定长度！")
    private String remark;

}
